package day8;

/**
 * @author oldliu
 * @since 1.0
 */
public class BubbleSort {
    public static void main(String[] args) {
        //冒泡排序
        double d[]={34,6,34.7,73,22,13,14,3,70};
        double temp;
        System.out.println("排序前：");
        for (int i = 0; i < d.length; i++) {
            System.out.print(d[i]+" ");
        }
        for(int i=0;i<d.length-1;i++){
            //每一个和隔壁的比较
            for (int j = 0; j < d.length-1-i; j++) {
                //d[j]和d[j+1]
                if(d[j]>d[j+1]){
                    temp=d[j];
                    d[j]=d[j+1];
                    d[j+1]=temp;
                }
            }
        }
        System.out.println();
        System.out.println("排序后：");
        for (int i = 0; i < d.length; i++) {
            System.out.print(d[i]+" ");
        }
    }
}
